package git.jas0nch.boottest.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * boottest
 *
 * @author: git.jas0nch
 * date: 2021-10-03
 */

// 扩展springMVC
@Configuration
//@EnableWebMvc: add this to stop the extensive function;
public class myMvcConfig implements WebMvcConfigurer {
    //index page
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("index");
        registry.addViewController("/index.html").setViewName("index");
        registry.addViewController("/success.html").setViewName("success");
    }

    // bean
    @Bean
    public LocaleResolver localeResolver(){
        return new MyLocaleResolver();
    }

//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new LoginHandlerIntercepter())
//                .addPathPatterns("/**")
//                .excludePathPatterns("/user/login","/index.html","/");
//    }
}
